//app.js
App({
  onLaunch: function () {
    //调用API从本地缓存中获取数据
    var logs = wx.getStorageSync('logs') || []
    logs.unshift(Date.now())
    wx.setStorageSync('logs', logs)
  },
  getUserInfo:function(cb){
    var that = this
    if (this.data.userInfo){
      typeof cb == "function" && cb(this.data.userInfo)
    }else{
      //调用登录接口
      wx.login({
        success: function () {
          wx.getUserInfo({
            success: function (res) {
              that.data.userInfo = res.userInfo
              typeof cb == "function" && cb(that.data.userInfo)
            }
          })
        }
      })
    }
  },
  data:{
    userInfo:null,
    host:"https://www.wjp147.cn/e2face/",
  }, 
  apiUrl: {
    subject: {
      list:'https://www.wjp147.cn/e2face/subject/api_list',
      view: 'https://www.wjp147.cn/e2face/subject/view',
      edit:'https://www.wjp147.cn/e2face/subject/edit'
    },
    strategy:{
      list:'https://www.wjp147.cn/e2face/strategy/apilist',
      serach: 'https://www.wjp147.cn/e2face/strategy/serach'
    },
    collect:{
      list: 'https://www.wjp147.cn/e2face/collect/api_list',
      add:'https://www.wjp147.cn/e2face/collect/save',
      del:'https://www.wjp147.cn/e2face/collect/api_del'
    } ,
    opinion: 'https://www.wjp147.cn/e2face/opinion',
    category: 'https://www.wjp147.cn/e2face/category'
  }
})